﻿namespace NEvoWeb.Modules.NB_Store
{
    using DotNetNuke.Entities.Modules;
    using DotNetNuke.Services.Exceptions;
    using DotNetNuke.Services.Localization;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Runtime.CompilerServices;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    public class ProductSearchSettings : ModuleSettingsBase
    {
        [AccessedThroughProperty("cboModule")]
        private DropDownList _cboModule;
        [AccessedThroughProperty("chkGo")]
        private CheckBox _chkGo;
        [AccessedThroughProperty("chkSearchImage")]
        private CheckBox _chkSearchImage;
        [AccessedThroughProperty("plGoCheck")]
        private UserControl _plGoCheck;
        [AccessedThroughProperty("plImgPath")]
        private UserControl _plImgPath;
        [AccessedThroughProperty("plModuleCombo")]
        private UserControl _plModuleCombo;
        [AccessedThroughProperty("plSearchCheck")]
        private UserControl _plSearchCheck;
        [AccessedThroughProperty("plSImgPath")]
        private UserControl _plSImgPath;
        [AccessedThroughProperty("txtImagePath")]
        private TextBox _txtImagePath;
        [AccessedThroughProperty("txtModule")]
        private Label _txtModule;
        [AccessedThroughProperty("txtSImagePath")]
        private TextBox _txtSImagePath;

        public override void LoadSettings()
        {
            try
            {
                if (!this.Page.IsPostBack)
                {
                    string defaultValue = Conversions.ToString(this.ModuleSettings["SearchResultsModule"]);
                    string str2 = Conversions.ToString(this.ModuleSettings["ShowGoImage"]);
                    string str3 = Conversions.ToString(this.ModuleSettings["ShowSearchImage"]);
                    if (defaultValue == "")
                    {
                        defaultValue = this.TabId.ToString();
                    }
                    SharedFunctions.populateTabsList(this.cboModule, this.PortalSettings, defaultValue);
                    if (this.cboModule.Items.FindByValue(defaultValue) != null)
                    {
                        this.cboModule.Items.FindByValue(defaultValue).Selected = true;
                    }
                    if (this.cboModule.Items.Count > 0)
                    {
                        this.txtModule.Text = this.cboModule.SelectedItem.Text;
                    }
                    else
                    {
                        this.txtModule.Text = DotNetNuke.Services.Localization.Localization.GetString("NoSearchModule", this.LocalResourceFile);
                    }
                    if (str2 != null)
                    {
                        this.chkGo.Checked = Conversions.ToBoolean(str2);
                    }
                    if (str3 != null)
                    {
                        this.chkSearchImage.Checked = Conversions.ToBoolean(str3);
                    }
                    this.txtImagePath.Text = Conversions.ToString(this.ModuleSettings["txtImagePath"]);
                    this.txtSImagePath.Text = Conversions.ToString(this.ModuleSettings["txtSImagePath"]);
                }
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exc = exception1;
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException((PortalModuleBase) this, exc);
                ProjectData.ClearProjectError();
            }
        }

        public override void UpdateSettings()
        {
            try
            {
                ModuleController controller = new ModuleController();
                if (this.cboModule.SelectedIndex != -1)
                {
                    controller.UpdateModuleSetting(this.ModuleId, "SearchResultsModule", this.cboModule.SelectedItem.Value);
                }
                controller.UpdateModuleSetting(this.ModuleId, "ShowGoImage", this.chkGo.Checked.ToString());
                controller.UpdateModuleSetting(this.ModuleId, "ShowSearchImage", this.chkSearchImage.Checked.ToString());
                controller.UpdateModuleSetting(this.ModuleId, "txtImagePath", this.txtImagePath.Text);
                controller.UpdateModuleSetting(this.ModuleId, "txtSImagePath", this.txtSImagePath.Text);
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exc = exception1;
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException((PortalModuleBase) this, exc);
                ProjectData.ClearProjectError();
            }
        }

        protected virtual DropDownList cboModule
        {
            get
            {
                return this._cboModule;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._cboModule = value;
            }
        }

        protected virtual CheckBox chkGo
        {
            get
            {
                return this._chkGo;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._chkGo = value;
            }
        }

        protected virtual CheckBox chkSearchImage
        {
            get
            {
                return this._chkSearchImage;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._chkSearchImage = value;
            }
        }

        protected virtual UserControl plGoCheck
        {
            get
            {
                return this._plGoCheck;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._plGoCheck = value;
            }
        }

        protected virtual UserControl plImgPath
        {
            get
            {
                return this._plImgPath;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._plImgPath = value;
            }
        }

        protected virtual UserControl plModuleCombo
        {
            get
            {
                return this._plModuleCombo;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._plModuleCombo = value;
            }
        }

        protected virtual UserControl plSearchCheck
        {
            get
            {
                return this._plSearchCheck;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._plSearchCheck = value;
            }
        }

        protected virtual UserControl plSImgPath
        {
            get
            {
                return this._plSImgPath;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._plSImgPath = value;
            }
        }

        protected virtual TextBox txtImagePath
        {
            get
            {
                return this._txtImagePath;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._txtImagePath = value;
            }
        }

        protected virtual Label txtModule
        {
            get
            {
                return this._txtModule;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._txtModule = value;
            }
        }

        protected virtual TextBox txtSImagePath
        {
            get
            {
                return this._txtSImagePath;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._txtSImagePath = value;
            }
        }
    }
}

